<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
  <form action="login" method="post">
    请输入用户名：<input name="username" /><br><br>
    请输入密码：<input name="password" /><br><br>
<!--    <button onclick="login()">登录</button>-->
    <input type="submit" value="登录">
      <a href="login">自动登录</a>
  </form>

<script>
  function login(){
      var username = document.getElementById("username").value;
      var password = document.getElementById("password").value;
      let xhr = new XMLHttpRequest();
      xhr.open("get","http://localhost:8080/demo1114/login?username="+username+"&password="+password);
      xhr.onreadystatechange = function (){
          if(xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300){
              //服务器端已经返回数据了
              console.log(xhr.responseText);
          } else{
              console.log(xhr.status);
          }
      }
      xhr.send();
  }

</script>
</body>
</html>